{literal}
<script type="text/javascript">

	{/literal}
		{if isset($smarty.cookies.weights) && $smarty.cookies.weights == 1}
		var weights = 1;
		{else}
		var weights = 0;
		{/if}
	{literal}

	var texts = ['Bez wag - zmień' , 'Z wagami - zmień' ];

	$(function(){
		$('#addProduct').validate()

		$('#defaultValues tr:last input').live('focus',function(){
			var tr = $(this).parent().parent();
			var totalStrlen = 0;

			tr.find('input').each(function(){totalStrlen = totalStrlen + $(this).val().length});

			if(totalStrlen == 0) {
				tr.after(tr.clone());
				}else{
					//alert(totalStrlen);
						}
		});
		$('.systems').click(function(){

				if($(this).attr('checked') == true && $(this).val() == 0){
					$('.metric').attr('disabled',true).addClass('disabled');
				}else{
					$('.metric').attr('disabled',false).removeClass('disabled');
				}

		});
		$('.systems:checked').click();


		$('.weight').change(function(){
			$('input.' + $(this).attr('rel')).val($(this).val());
		}).keyup(function(){
			$('input.' + $(this).attr('rel')).val($(this).val());
		});


		$('.weightButton').click(function(){
			console.log(weights);
			$('#weightsTd').toggle();
			weights = 1 - weights;
			document.cookie='weights='+weights;
			$(this).text(texts[weights]);
			return false;
		});
	});
		
</script>


{/literal}
<h1>Edytujesz cechę</h1>

<form method="post" enctype="multipart/form-data" id="addProduct">
{mainoptions title="Dane dla poszczególnych wersji językowych"}
	{assign var=class value=colapse}
	{foreach from=$languages item=lang}
	{capture assign=title}Dane języka: {$lang->getName()}{/capture}
	{mainoptions title=$title class=$class}
	<table cellpadding="0" cellspacing="0" width="100%" class="commonTable">
		<tr>
			<th>Opis</th>
			<td><textarea name="description[{$lang->getId()}]">{assign var=desc value=$obj->getDescription($lang->getId())}{$desc->getDescription()}</textarea></td>
		</tr>
		<tr>
			<th>Opis</th>
			<td>{capture assign=text}text_{$lang->getId()}{/capture}{insertFckEditor name=$text value=$desc->getText()}</td>
		</tr>
	</table>
	{/mainoptions}
	{assign var=class value=expand}
	{assign var=required value=1}
	{/foreach}
{/mainoptions}



{mainoptions title="Dane ogólne"}
	<table cellpadding="0" cellspacing="0" width="100%" class="commonTable">
		<tr>
			<th>Kategoria</th>
			<td>
				<select name="id_category">
					{foreach from=$categories item=category}
					{if $category->getChildren()|@count gt 0}
					<option {if $obj->getIdCategory() eq $category->getId()}selected="selected"{/if} value="{$category->GetId()}">{$category->getName()}</option>
						{foreach from=$category->getChildren() item=child}
						<option {if $obj->getIdCategory() eq $child->getId()}selected="selected"{/if} value="{$child->getId()}"> - {$child->getName()}</option>
						{/foreach}
					{else}
					<option {if $obj->getIdCategory() eq $category->getId()}selected="selected"{/if} value="{$category->GetId()}">{$category->getName()}</option>
					{/if}
					{/foreach}
				</select>
			</td>
		</tr>
		<tr>
			<th>Grupa</th>
			<td>
				<select name="id_property_group">
					{foreach from=$groups item=category}
					<option  {if $obj->getIdPropertyGroup() eq $category->getId()}selected="selected"{/if} value="{$category->GetId()}">{$category->getName()}</option>
					{/foreach}
				</select>
			</td>
		</tr>
		<tr>
			<th>Aktywny:</th>
			<td>
				<input type="radio" {if $obj->getActive() eq 1}checked="checked"{/if} value="1" id="active_1" name="active" /><label for="active_1">tak</label>
				<input type="radio" {if $obj->getActive() eq 0}checked="checked"{/if} value="0" id="active_0"  name="active"  /><label for="active_0">nie</label>
			</td>
		</tr>
		<tr>
			<th>Systemy miar:</th>
			<td>
				<input class="systems" type="radio" {if $obj->getType() eq 1}checked="checked"{/if} value="1" id="type_1" name="type" /><label for="type_1">dwa</label>
				<input class="systems" type="radio" {if $obj->getType() eq 0}checked="checked"{/if} value="0" id="type_0"  name="type"  /><label for="type_0">jeden</label>
			</td>
		</tr>
		<tr style="display: none;">
			<th>Pokaż na listach:</th>
			<td>
				<input type="radio" {if $obj->getShowInList() eq 1}checked="checked"{/if} value="1" id="show_in_list_1" name="show_in_list" /><label for="show_in_list_1">tak</label>
				<input type="radio" {if $obj->getShowInList() eq 0}checked="checked"{/if} value="0" id="show_in_list_0"  name="show_in_list"  /><label for="show_in_list_0">nie</label>
			</td>
		</tr>
		<tr style="display: none;">
			<th>Pokaż przy uzytkownikach:</th>
			<td>
				<input type="radio" {if $obj->getShowInUser() eq 1}checked="checked"{/if} value="1" id="show_in_user_1" name="show_in_user" /><label for="show_in_user_1">tak</label>
				<input type="radio" {if $obj->getShowInUser() eq 0}checked="checked"{/if} value="0" id="show_in_user_0"  name="show_in_user"  /><label for="show_in_user_0">nie</label>
			</td>
		</tr>
		<tr style="display: none;">
			<th>Pokaż w wyszukiwarce:</th>
			<td>
				<input type="radio" {if $obj->getShowInSearch() eq 1}checked="checked"{/if} value="1" id="show_in_search_1" name="show_in_search" /><label for="show_in_search_1">tak</label>
				<input type="radio" {if $obj->getShowInSearch() eq 0}checked="checked"{/if} value="0" id="show_in_search_0"  name="show_in_search"  /><label for="show_in_search_0">nie</label>
			</td>
		</tr>
		<tr>
			<th>Pokaż w filtrach:</th>
			<td>
				<input type="radio" {if $obj->getShowInFilters() eq 1}checked="checked"{/if} value="1" id="show_in_filters_1" name="show_in_filters" /><label for="show_in_filters_1">tak</label>
				<input type="radio" {if $obj->getShowInFilters() eq 0}checked="checked"{/if} value="0" id="show_in_filters_0"  name="show_in_filters"  /><label for="show_in_filters_0">nie</label>
			</td>
		</tr>
		<tr>
			<th>Waga:</th>
			<td>
				<input type="text" name="weight" value="{$obj->getWeight()}" />
			</td>
		</tr>

	</table>

{/mainoptions}

{if isset($smarty.cookies.weights) && $smarty.cookies.weights == 1}
	{capture assign=button}Wartości domyślne - aby usunąć wartość wyczyść odpowiednie wiersze (<a href="#" class="weightButton">Z wagami - zmień</a>){/capture}
{else}
	{capture assign=button}Wartości domyślne - aby usunąć wartość wyczyść odpowiednie wiersze (<a href="#" class="weightButton">Bez wag - zmień</a>){/capture}
{/if}

{if $obj->hasDefaultValues()}
{mainoptions title=$button}
	<table class="commonTable" id="defaultValues" cellspacing="0" cellpadding="0" border="0">
		<tr><td><table class="commonTable" id="defaultValues" cellspacing="0" cellpadding="0" border="0">
		{assign var=defaults value=$obj->getDefaultValues()}
		<tr>
			<th>
				Prefix
			</th>
			<th>
				Wartość
			</th>
			<th>
				Postfix
			</th>
		</tr>
			{foreach from=$defaults.0 item=val key=k1}
		<tr>
			<td>
				<input type="text" size="5" name="default_prepend[{$val->getId()}]" value="{$val->getPrepend()}" />
			</td>
			<td>
				<input type="text" size="5" name="default_value[{$val->getId()}]" value="{$val->getValue()}" />
			</td>
			<td>
				<input type="text" size="5" name="default_append[{$val->getId()}]" value="{$val->getAppend()}" />
				<input type="hidden" class="weight{$k1}" name="default_weight[{$val->getId()}]" value="{$k1}" />
			</td>
		</tr>
			{/foreach}

		</table></td><td valign="top"><table class="commonTable" id="defaultValues" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<th>
				Prefix - metric
			</th>
			<th>
				Wartość - metric
			</th>
			<th>
				Postfix - metric
			</th>
		</tr>
			{foreach from=$defaults.1 item=val key=k2}
		<tr>
			<td>
				<input class="metric" type="text" size="5" name="default_prepend[{$val->getId()}]" value="{$val->getPrepend()}" />
			</td>
			<td>
				<input class="metric" type="text" size="5" name="default_value[{$val->getId()}]" value="{$val->getValue()}" />
			</td>
			<td>
				<input class="metric" type="text" size="5" name="default_append[{$val->getId()}]" value="{$val->getAppend()}" />
				<input type="hidden" class="weight{$k2}" name="default_weight[{$val->getId()}]" value="{$k2}" />
			</td>
		</tr>
			{/foreach}

		</table></td><td valign="top" id="weightsTd" {if !isset($smarty.cookies.weights) || $smarty.cookies.weights == 0}style="display: none;"{/if}><table class="commonTable" id="defaultValues" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<th>
				Waga
			</th>
		</tr>
			{foreach from=$defaults.0 item=val key=k3}
		<tr>
			<td>
				<input type="text" class="weight" rel="weight{$k3}" value="{$k3}" />
			</td>
		</tr>
			{/foreach}

		</table></td></tr>
	</table>
{/mainoptions}
{/if}
{mainoptions title="Wartości domyślne"}
	<table class="commonTable" id="defaultValues" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<th>
				Prefix
			</th>
			<th>
				Wartość
			</th>
			<th>
				Postfix
			</th>
			<th>
				Prefix - metric
			</th>
			<th>
				Wartość - metric
			</th>
			<th>
				Postfix - metric
			</th>
		</tr>
		<tr>
			<td>
				<input type="text" size="5" name="property_prepend[0][]" />
			</td>
			<td>
				<input type="text" size="5" name="property_value[0][]" />
			</td>
			<td>
				<input type="text" size="5" name="property_append[0][]" />
			</td>
			<td>
				<input class="metric" type="text" size="5" name="property_prepend[1][]" />
			</td>
			<td>
				<input class="metric" type="text" size="5" name="property_value[1][]" />
			</td>
			<td>
				<input class="metric" type="text" size="5" name="property_append[1][]" />
			</td>
		</tr>
	</table>
{/mainoptions}

{mainoptions}
	<input type="submit" value="Zapisz i przejdź do listy" />
	<input type="button" value="Anuluj" onclick="document.location='{url property=index}'" />
{/mainoptions}
</form>
